package student.dao;
import java.sql.*;

public class DataBase {
	private static final String driver = "com.mysql.jdbc.Driver";
	private static final String schema = "test";
	private static final String name = "root";
	private static final String password = "6328858";
	private static final String url = 
		"jdbc:mysql://localhost:3306/"+schema+"?user="
		+name+"&password="+password+"&useUnicode=true&characterEncoding=GBK";
	
	private Connection con;
	private Statement st;
	public DataBase()
	{
		try
		{
			Class.forName(driver);
			con = DriverManager.getConnection(url);
			st = con.createStatement();
		}
		catch(ClassNotFoundException cnfe)
		{
			cnfe.printStackTrace();
		}
		catch(SQLException sqle)
		{
			sqle.printStackTrace();
		}
	}
	public int executeUpdate(String sql)throws SQLException
	{
		return st.executeUpdate(sql);
	}
	public ResultSet executeQuery(String sql)throws SQLException
	{
		return st.executeQuery(sql);
	}
}
